package core.base;

import java.util.HashMap;
import java.util.Map;

import core.ApplicationManager;
import core.helpers.GmailHelper;

import javax.mail.MessagingException;

public abstract class MailBase
{
	protected static ApplicationManager manager;
	public static Map<String, String> inboxMessages = new HashMap<String, String>();
	public static Map<String, String> spamMessages = new HashMap<String, String>();
	public static String messageContent = null;

	/**
	 * Initializes MailBase
	 * @param p_manager ApplicationManager instance
	 */
	public MailBase(ApplicationManager p_manager)
	{
		manager = p_manager;
	}

	public abstract Boolean findByEmail(String p_email);

	public abstract String getUidBySubject(Map<String, String> actualMessageSubjects, String[] expectedMessageSubjects);

	public abstract String saveByUid(String muid);

	public abstract String getMessageContent(String[] p_title, String p_email);

	public void close()
	{
		try
		{
			GmailHelper.imapStore.close();
			GmailHelper.isSpam = false;
		}
		catch (MessagingException e)
		{
			manager.log().info(e.toString());
		}
	}
}
